'use client';
import {memo, ReactNode, useRef} from 'react';
import {i18nextInit} from './initClient';

export const isLanguage = (path: string) => {
    return ['en', 'zh'].includes(path);
};

const I18nProvider = memo(function I18nProvider({children, lng = 'en'}: {children: ReactNode, lng: string}) {
    const lngRef = useRef<string>();

    if (!lngRef.current) {
        i18nextInit(lng);
        lngRef.current = lng;
    }

    return <>{children}</>;
});

export default I18nProvider;
